home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / STOZ.INC < prev    next >
Text File  |  1989-06-02  |  3KB  |  82 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*------------------------------------------
  14.  *
  15.  * ztos - convert a zero terminated string into a turbo string (tpas 4.0)
  16.  *
  17.  *   (C) 1988 Samuel H. Smith (rev. 12-01-88)
  18.  *
  19.    Inline(
  20.      $C4/$7E/$06/           {   les di,[bp]6         ;es:di -> st[0]}
  21.      $26/                   {   es:}
  22.      $8A/$0D/               {   mov cl,[di]          ;cl = length}
  23.      $FE/$C1/               {   inc cl}
  24.                             {next:}
  25.  *
  26.  *)
  27.  
  28. {$F+} procedure ztos(var z: zstring;
  29.                      var s: string); {$F-}
  30. begin
  31.  
  32.    Inline(
  33.        $1E             {    push ds                            }
  34.       /$FC             {    cld             ;direction fwd     }
  35.       /$C5/$76/$08     {    lds si,[bp]8    ;ds:si --> z[0]    }
  36.       /$C4/$7E/$04     {    les di,[bp]4    ;es:di --> s[0]    }
  37.       /$47             {    inc di          ;skip over length  }
  38.       /$B1/$FF         {    mov cl,=-1      ;length counter    }
  39.  
  40.                        { loop:                                 }
  41.       /$FE/$C1         {    inc cl          ;count a byte      }
  42.       /$AC             {    lods(b)         ;al=*ds:si++       }
  43.       /$AA             {    stos(b)         ;*es:di++=al       }
  44.       /$3C/$00         {    cmp al,=0       ;repeat until zero }
  45.       /$75/$F8         {    jnz loop                           }
  46.  
  47.       /$C5/$7E/$04     {    lds di,[bp]4    ;store the length  }
  48.       /$88/$0D         {    mov [di],cl     ;ds:di=length      }
  49.       /$1F             {    pop ds                             }
  50.    );
  51.  
  52. end;
  53.  
  54.  
  55. (*------------------------------------------
  56.  *
  57.  * stoz - convert a turbo string into a zero terminated string
  58.  *
  59.  *)
  60.  
  61. {$F+} procedure stoz(var s: string;
  62.                      var z: zstring); {$F-}
  63. begin
  64.  
  65.    Inline(
  66.        $1E             {    push ds                           }
  67.       /$FC             {    cld             ;direction fwd    }
  68.       /$C4/$7E/$04     {    les di,[bp]4    ;es:di --> z[0]   }
  69.       /$C5/$76/$08     {    lds si,[bp]8    ;ds:si --> s[0]   }
  70.       /$AC             {    lods(b)                           }
  71.       /$8A/$C8         {    mov cl,al                         }
  72.       /$B5/$00         {    mov ch,=0       ;cx is length     }
  73.       /$F2/$A4         {    rep movs(b)     ;copy the string  }
  74.       /$B0/$00         {    mov al,=0                         }
  75.       /$AA             {    stos(b)         ;append the zero  }
  76.       /$1F             {    pop ds                            }
  77.    );
  78.  
  79. end;
  80.  
  81.  
  82.